package com.yeda.engine.util;

import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @projectName: beautiful
 * @package: com.beautiful.util
 * @className: ImageUtil
 * <p>
 * 图片工具类
 * </p>
 * @author: 云尚智动-王世玺
 * @date: 2021/11/28 22:29
 * @version: 1.0
 */
public class ImageUtil {
    public static boolean  chekImageType(List<MultipartFile> file, HttpServletRequest request ){
        boolean imageType=true;
        for (MultipartFile f : file){
            // 文件原名
            String fileNameOriginal = f.getOriginalFilename();
            String mimeType = request.getServletContext().getMimeType(fileNameOriginal);
            String type = mimeType.split("/")[0];
            if (!type.equals("image")){
                imageType= false;
            }
        }
        return imageType;
    }


}
